package com.alphawavesgames.jdroidengine;

import com.alphawavesgames.engine.game.GameContainer;
import com.alphawavesgames.engine.rendering.RenderContainer;
import com.alphawavesgames.engine.rendering.SpriteRenderer.Sprite;
import com.alphawavesgames.engine.rendering.TextureManager.TextureHandle;

/**
 *
 * @author Duncan
 */
public class TestSprite implements GameContainer
{
    private Sprite m_testSprite;
    protected float m_x;
    protected float m_y;

    public void initialise()
    {
        m_x = -32;
        m_y = -32;
        TextureHandle splashTex = RenderContainer.getRenderContainer().getTextureManager().createTexture( R.drawable.knightiso );
        m_testSprite = RenderContainer.getRenderContainer().getSpriteRenderer().createSprite( splashTex );
        m_testSprite.setPosAndExtents( -32, -32, 64, 64 );
    }

    public void finalise()
    {

    }

    public void update( float frameDelta )
    {
        m_x += 10.0f * frameDelta;
        if( m_x > 640 )
        {
            m_x = -64;
        }
        m_x = 0;

        m_y += 10.0f * frameDelta;

        if( m_y > 200 )
        {
            m_y = -32;
        }
    }

    public void render()
    {
        m_testSprite.setPosAndExtents( (int)m_x, (int)m_y, 64, 64 );
        m_testSprite.submitDraw();
    }

    public boolean isQuitting()
    {
        return false;
    }

    public void onEngineInitialised()
    {

    }

}
